cmake_minimum_required(VERSION 3.15)

project(VTKExamples)

include(CheckIncludeFileCXX)

# 判断当前目录是否为 cmake的根目录,如果不是,则是被其他项目引用的,不需要编译测试,工具模块
message("AO当前文件根目录 (CMAKE_CURRENT_SOURCE_DIR) ${CMAKE_CURRENT_SOURCE_DIR}")
message("AO当前项目根目录 (CMAKE_SOURCE_DIR) ${CMAKE_SOURCE_DIR}")

# 当前文件路径
set(AO_FILE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
# 项目根CMakeLists.txt文件路径
set(AO_PROJ_ROOT "${CMAKE_SOURCE_DIR}")
set(CMAKE_MODULE_PATH "${AO_FILE_ROOT}/cmake;${CMAKE_MODULE_PATH}")
if("${AO_FILE_ROOT}" STREQUAL "${AO_PROJ_ROOT}")
	set(BUILD_AS_PROJ TRUE)
	message("作为单个工程编译")
	#include(${AO_PROJ_ROOT}/cmake/ThirdSupport.cmake)
else ()
	set(BUILD_AS_LIB TRUE)
	message("作为嵌入库编译")
endif()

ADD_DEFINITIONS("-DDEFAULT_AO_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/data\"")

# 头文件
#include(all_in_one)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(EvnSetup)
include(ResSetup)


# 添加 openccasec 头文件
find_package(OpenCASCADE CONFIG REQUIRED)
include_directories(${OpenCASCADE_INCLUDE_DIR})

# 添加库文件
link_directories(${OpenCASCADE_LIBRARY_DIR})
message(STATUS "OpenCASCADE_LIBRARY_DIR: ${OpenCASCADE_LIBRARY_DIR}")

set(Qt5_DIR "D:/software/ide/qt_5_15_2/5.15.2/msvc2019_64/lib/cmake/Qt5")
SET(QT_SDK_DIR "D:/software/ide/qt_5_15_2/5.15.2/msvc2019_64" CACHE PATH "QT SDK DIR" FORCE)
message("在CMAKE中配置 QT_SDK_DIR 选项指定QT路径; 当前路径: ${QT_SDK_DIR}")
SET(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/Install CACHE PATH "Installation path" FORCE)
# 在 find_package 之前设置 Qt5_DIR
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

message(STATUS "Setting Qt5_DIR to: ${Qt5_DIR}")
message( "QT_VERSION: ${QT_VERSION}  QT_VERSION_MAJOR: ${QT_VERSION_MAJOR}")

# 添加core目录下的头文件到项目
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/core)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/extern/ElaWidgetTools)

# 添加目录
add_subdirectory(extern)   # 第三方库
add_subdirectory(core)  # core代码
add_subdirectory(app)   # 主函数
add_subdirectory(test)   # 测试

